<?php
include '../conn.php';
include 's-cookie.php';
?>
<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>我的课题-教师端</title>
    <link rel="stylesheet" type="text/css" href="../css/htmleaf-demo.css">
    <link rel="stylesheet" type="text/css" href="../css/nav.css">
    <link rel="stylesheet" type="text/css" href="../fonts/iconfont.css">
    <link rel="stylesheet" href="../css/bootstrap-theme.css"/>
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <link rel="stylesheet" href="../css/bootstrap-theme.min.css"/>
    <link rel="stylesheet" href="../css/bootstrap.css"/>
    <script type="text/javascript" src="../js/bootstrap3.0.3.min.js"></script>
    <link rel="stylesheet" type="text/css" href="../css/style.css">


</head>

<body class="bodycolor">

<nav class="navbar navbar-default navbar-fixed-top" style="clear: left;">
    <div class="container">
        <div class="navbar-right navfont" id="navbar-collapse">
            <p>华软网络技术系毕业管理系统</p>
        </div>
        <a href="s-cookie.php?cookie=out" id="out">退出</a>
    </div>

</nav>

<div class="nav topx navbackground-s" id="nav">
    <div>

        <div style="border-bottom:1px solid rgba(255,255,255,.1)"><img src="../images/mini.png"></div>
    </div>
    <ul>
        <li class="nav-item">
            <a href="s-index.php"><i class="my-icon nav-icon icon_2"></i><span>首页</span><i class="my-icon nav-more"></i></a>

        </li>
        <li class="nav-item">
            <a href="s-mykt.php"><i class="my-icon nav-icon icon_1"></i><span>我的课题</span><i
                    class="my-icon nav-more"></i></a>
        </li>

        <li class="nav-item">
            <a href="s-examination.php"><i class="my-icon nav-icon icon_3"></i><span>成绩考核表</span><i
                    class="my-icon nav-more"></i></a>

        </li>
        <li class="nav-item">
            <a href="s-information.php"><i class="my-icon nav-icon icon_4"></i><span>我的资料</span><i
                    class="my-icon nav-more"></i></a>
        </li>
        <li class="nav-item">
            <a href="teachresearch.php"><i class="my-icon nav-icon icon_6"></i><span>选课</span><i
                    class="my-icon nav-more"></i></a>
        </li>
    </ul>
</div>


<div class="indexborder top1">
    <div class="tablediv">

        <div width="100%">
            <div>
                <!-- style="margin-left: 70px;"-->
                <div class="box-inline indexdiv2 panel panel-default auto" align="center">
                    <div class="panel panel-primary panel-success">
                        <div class="panel-heading" style="padding: 0px;color: black;font-style:initial;">
                            <h3 class="panel-title " style="background-color: #536d90;padding: 15px;">我的课题</h3>
                        </div>
                        <div class="panel-body">
                            <!--                            <div class="table-responsive">-->
                            <table class="table  table-hover  table-striped">

                                <div id="fade" class="black_overlay-s">
                                    <!--//弹窗-->
                                </div>
                                <div id="MyDiv" class="white_content_small">
                                    <div style="text-align: right; cursor: default; height: 40px;">
                                        <span style="font-size: 16px;" onclick="CloseDiv('MyDiv','fade')">关闭</span>
                                    </div>
                                    <form action="proTask.php" method="post" enctype="multipart/form-data">
                                        <input type="text" name="projectid" id="projectid"/>

                                        <h3>任务书</h3>
                                        <input type="file" name="upassfile" size="15">
                                        <input type="submit" name="asstask" value="" id="task"/>
                                        <a href="" id="taskhrf"></a>

                                        <h3>答辩稿</h3>
                                        <input type="file" name="uptaskfile" size="15">
                                        <input type="submit" name="draft" value="" id="draft"/ >
                                        <a href="" id="drafthrf"></a>
                                    </form>
                                </div>

                                <thead>
                                <tr class="thcolor">

                                    <th>课题名</th>
                                    <th>类别</th>
                                    <th>来源</th>
<!--                                    <th>简介</th>-->
                                    <th>指导教师</th>
                                    <th>学生</th>
                                    <th>任务书</th>
                                    <th>答辩稿</th>
                                    <th>查看</th>

                                </tr>
                                </thead>
                                <tbody>
                                <?php

                                $sql = "SELECT p.ProjectName, p.Category, p.ProjectOrigin, t.TeacherName, s.StudentName,p.ProjectId,p.Summary 	FROM project AS p
															JOIN teacher AS t ON p.Teacher_TeacherId = t.TeacherId
															JOIN student AS s ON p.Student_StudentId = s.StudentId
															where s.StudentId=" . $_SESSION["s-id"] . " and s.Year=" . $_SESSION["s-Year"];
                                $result = mysqli_query($conn, $sql);
                                while ($row = mysqli_fetch_array($result)) {
                                    ?>
                                    <tr>

                                        <td data-label="课题名"><?= $row[0] ?></td>
                                        <td data-label="类别"><?= $row[1] ?></td>
                                        <td data-label="来源"><?= $row[2] ?></td>
                                        <td data-label="指导教师"><?= $row[3] ?></td>
                                        <td data-label="学生"><?= $row[4] ?></td>
                                        <td data-label="任务书">
                                            <?$Asql = "select Assignment from project WHERE ProjectId=$row[5]";
                                            $Aresult = $conn->query($Asql);
                                            $Arow = $Aresult->fetch_array();
                                            $Dsql = "select Draft from project WHERE ProjectId=$row[5]";
                                            $Dresult = $conn->query($Dsql);
                                            $Drow = $Dresult->fetch_array();
                                            ?>
                                            <a onclick="ShowDiv('MyDiv','fade',<?= $row[5] ?>,'<?= $Arow[0] ?>','<?= $Drow[0] ?>')">任务书</a>

                                        </td>

                                        <td data-label="答辩稿">
                                            <a onclick="ShowDiv('MyDiv','fade',<?= $row[5] ?>,'<?= $Arow[0] ?>','<?= $Drow[0] ?>')">答辩稿</a>


                                        </td>
                                        <td data-label="查看"><button onclick="check(<?=$row[5]?>)">查看</button></td>

                                    </tr>
                                <?php
                                }
                                ?>
                                </tbody>
                            </table>
                        </div>
                        <!--        </div>-->
                    </div>
                </div>

                <script type="text/javascript" src="../js/nav.js"></script>
                <script type="text/javascript" src="../layer/layer.js"></script>
                <script>
                    window.jQuery || document.write('<script src="../js/jquery-1.11.0.min.js"><\/script>')
                </script>
                <script type="text/javascript">
                    //弹窗实现
                    //弹出隐藏层
                    function ShowDiv(show_div, bg_div, id, asspath, draftpath) {
                        document.getElementById('projectid').value = id;
                        if (asspath != "") {
                            document.getElementById('task').value = '更新';
                            document.getElementById('taskhrf').href = asspath;
                            document.getElementById('taskhrf').innerText = '下载';
                        } else {
                            document.getElementById('task').value = '上传任务书';
                            document.getElementById('taskhrf').href = '';
                            document.getElementById('taskhrf').innerText = '';
                        }
                        if (draftpath != "") {
                            document.getElementById('draft').value = '更新';
                            document.getElementById('drafthrf').href = draftpath;
                            document.getElementById('drafthrf').innerText = '下载';
                        } else {
                            document.getElementById('draft').value = '上传答辩稿';
                            document.getElementById('drafthrf').href = '';
                            document.getElementById('drafthrf').innerText = '';
                        }

                        document.getElementById(show_div).style.display = 'block';
                        document.getElementById(bg_div).style.display = 'block';
                        var bgdiv = document.getElementById(bg_div);
                        bgdiv.style.width = document.body.Width;
                        // bgdiv.style.height = $(document).height();
                        $("#" + bg_div).height($(document).height());
                    }
                    ;
                    //关闭弹出层
                    function CloseDiv(show_div, bg_div) {
                        document.getElementById(show_div).style.display = 'none';
                        document.getElementById(bg_div).style.display = 'none';
                    }
                    ;
                </script>
                <script type="text/javascript">  //弹窗实现
                    function check(id) {
                        var path = "../taskinfo.php?projectId=" + id;
                        alert(path);
//                        alert("123");

                        layer.open({
                            type: 1,
                            area: ['80%', '80%'],
                            shadeClose: true, //点击遮罩关闭
                            content: "<iframe src=''  width='98%' height='94%' name=main frameborder= scrolling=NO id='testFrame'></iframe>"
                        });
                        var t = document.getElementById("testFrame");
                        t.src = path;
                    }
                </script>


</body>

</html>